---
# tasks file for configuring_app_servers
- name: Create folders for apps
  file:
    path: /apps/{{ item.name }}/shared/tmp/pids/
    state: directory
    owner: "{{ item.user }}"
    group: "{{ item.user }}"
    mode: 0775
    recurse: true
  loop: "{{ app_folders }}"

- name: Copy files for apps
  copy:
    src: "{{ item.src_path }}"
    dest: "{{ item.dst_path }}"
    owner: "{{ item.user }}"
    group: "{{ item.user }}"
    mode: "{{ item.mode }}"
  loop: "{{ file_vars }}"
  notify: Reload nginx

- name: enable services
  systemd:
    name: "{{ item.name }}"
    enabled: yes
    masked: no
  loop: "{{ app_folders }}"
  notify: Reread systemd

- name: run apps
  systemd:
    state: started
    name: "{{ item.name }}"
  loop: "{{ app_folders }}"
